home *** CD-ROM | disk | FTP | other *** search
/ Windows Game Programming for Dummies (2nd Edition) / WinGamProgFD.iso / pc / DirectX SDK / DXSDK / samples / Multimedia / VBSamples / DirectInput / Feedback / ForceFeedback.frm (.txt) next >
Encoding:
Visual Basic Form  |  2001-10-08  |  65.3 KB  |  1,390 lines

  1. VERSION 5.00
  2. Object = "{831FDD16-0C5C-11D2-A9FC-0000F8754DA1}#2.0#0"; "MSCOMCTL.OCX"
  3. Begin VB.Form frmForceFeedback 
  4.    BorderStyle     =   3  'Fixed Dialog
  5.    Caption         =   "VB Force Feedback"
  6.    ClientHeight    =   7020
  7.    ClientLeft      =   45
  8.    ClientTop       =   330
  9.    ClientWidth     =   9315
  10.    Icon            =   "ForceFeedback.frx":0000
  11.    LinkTopic       =   "Form1"
  12.    MaxButton       =   0   'False
  13.    MinButton       =   0   'False
  14.    ScaleHeight     =   7020
  15.    ScaleWidth      =   9315
  16.    StartUpPosition =   2  'CenterScreen
  17.    Begin VB.Frame frameDirection 
  18.       Caption         =   "Direction"
  19.       Height          =   2895
  20.       Left            =   6720
  21.       TabIndex        =   70
  22.       Top             =   3960
  23.       Width           =   2415
  24.       Begin VB.OptionButton optDirection 
  25.          Caption         =   "Option1"
  26.          Height          =   210
  27.          Index           =   0
  28.          Left            =   1080
  29.          TabIndex        =   78
  30.          Top             =   480
  31.          Value           =   -1  'True
  32.          Width           =   200
  33.       End
  34.       Begin VB.OptionButton optDirection 
  35.          Caption         =   "Option2"
  36.          Height          =   210
  37.          Index           =   4
  38.          Left            =   1080
  39.          TabIndex        =   77
  40.          Top             =   2280
  41.          Width           =   200
  42.       End
  43.       Begin VB.OptionButton optDirection 
  44.          Caption         =   "Option3"
  45.          Height          =   210
  46.          Index           =   6
  47.          Left            =   240
  48.          TabIndex        =   76
  49.          Top             =   1380
  50.          Width           =   200
  51.       End
  52.       Begin VB.OptionButton optDirection 
  53.          Caption         =   "Option4"
  54.          Height          =   210
  55.          Index           =   2
  56.          Left            =   1920
  57.          TabIndex        =   75
  58.          Top             =   1320
  59.          Width           =   200
  60.       End
  61.       Begin VB.OptionButton optDirection 
  62.          Caption         =   "Option5"
  63.          Height          =   210
  64.          Index           =   7
  65.          Left            =   480
  66.          TabIndex        =   74
  67.          Top             =   840
  68.          Width           =   200
  69.       End
  70.       Begin VB.OptionButton optDirection 
  71.          Caption         =   "Option6"
  72.          Height          =   210
  73.          Index           =   1
  74.          Left            =   1680
  75.          TabIndex        =   73
  76.          Top             =   840
  77.          Width           =   200
  78.       End
  79.       Begin VB.OptionButton optDirection 
  80.          Caption         =   "Option7"
  81.          Height          =   210
  82.          Index           =   5
  83.          Left            =   480
  84.          TabIndex        =   72
  85.          Top             =   1920
  86.          Width           =   200
  87.       End
  88.       Begin VB.OptionButton optDirection 
  89.          Caption         =   "Option8"
  90.          Height          =   210
  91.          Index           =   3
  92.          Left            =   1680
  93.          TabIndex        =   71
  94.          Top             =   1920
  95.          Width           =   200
  96.       End
  97.    End
  98.    Begin VB.Frame frameEnvelope 
  99.       Caption         =   "Envelope"
  100.       Height          =   2895
  101.       Left            =   3720
  102.       TabIndex        =   56
  103.       Top             =   3960
  104.       Width           =   2775
  105.       Begin MSComctlLib.Slider sldEnvelope 
  106.          Height          =   255
  107.          Index           =   0
  108.          Left            =   240
  109.          TabIndex        =   58
  110.          Top             =   855
  111.          Width           =   2295
  112.          _ExtentX        =   4048
  113.          _ExtentY        =   450
  114.          _Version        =   393216
  115.          LargeChange     =   100
  116.          SmallChange     =   10
  117.          Max             =   10000
  118.          SelStart        =   10000
  119.          TickFrequency   =   1000
  120.          Value           =   10000
  121.       End
  122.       Begin VB.CheckBox chkEnvelope 
  123.          Caption         =   "Use envelope"
  124.          Height          =   255
  125.          Left            =   720
  126.          TabIndex        =   57
  127.          Top             =   280
  128.          Width           =   1335
  129.       End
  130.       Begin MSComctlLib.Slider sldEnvelope 
  131.          Height          =   255
  132.          Index           =   1
  133.          Left            =   240
  134.          TabIndex        =   59
  135.          Top             =   1380
  136.          Width           =   2295
  137.          _ExtentX        =   4048
  138.          _ExtentY        =   450
  139.          _Version        =   393216
  140.          LargeChange     =   10000
  141.          SmallChange     =   1000
  142.          Max             =   5000000
  143.          TickFrequency   =   500000
  144.       End
  145.       Begin MSComctlLib.Slider sldEnvelope 
  146.          Height          =   255
  147.          Index           =   2
  148.          Left            =   240
  149.          TabIndex        =   60
  150.          Top             =   1965
  151.          Width           =   2295
  152.          _ExtentX        =   4048
  153.          _ExtentY        =   450
  154.          _Version        =   393216
  155.          LargeChange     =   100
  156.          SmallChange     =   10
  157.          Max             =   10000
  158.          SelStart        =   10000
  159.          TickFrequency   =   1000
  160.          Value           =   10000
  161.       End
  162.       Begin MSComctlLib.Slider sldEnvelope 
  163.          Height          =   255
  164.          Index           =   3
  165.          Left            =   240
  166.          TabIndex        =   61
  167.          Top             =   2520
  168.          Width           =   2295
  169.          _ExtentX        =   4048
  170.          _ExtentY        =   450
  171.          _Version        =   393216
  172.          LargeChange     =   1000
  173.          SmallChange     =   100
  174.          Max             =   5000000
  175.          TickFrequency   =   500000
  176.       End
  177.       Begin VB.Label lblEnvelope 
  178.          AutoSize        =   -1  'True
  179.          Caption         =   "0"
  180.          Height          =   195
  181.          Index           =   3
  182.          Left            =   1440
  183.          TabIndex        =   69
  184.          Top             =   2325
  185.          Width           =   90
  186.       End
  187.       Begin VB.Label lblEnvelope 
  188.          AutoSize        =   -1  'True
  189.          Caption         =   "10000"
  190.          Height          =   195
  191.          Index           =   2
  192.          Left            =   1440
  193.          TabIndex        =   68
  194.          Top             =   1740
  195.          Width           =   450
  196.       End
  197.       Begin VB.Label lblEnvelope 
  198.          AutoSize        =   -1  'True
  199.          Caption         =   "0"
  200.          Height          =   195
  201.          Index           =   1
  202.          Left            =   1440
  203.          TabIndex        =   67
  204.          Top             =   1170
  205.          Width           =   90
  206.       End
  207.       Begin VB.Label lblEnvelope 
  208.          AutoSize        =   -1  'True
  209.          Caption         =   "10000"
  210.          Height          =   195
  211.          Index           =   0
  212.          Left            =   1440
  213.          TabIndex        =   66
  214.          Top             =   600
  215.          Width           =   450
  216.       End
  217.       Begin VB.Label Label20 
  218.          AutoSize        =   -1  'True
  219.          Caption         =   "Fade Time:"
  220.          Height          =   195
  221.          Left            =   510
  222.          TabIndex        =   65
  223.          Top             =   2325
  224.          Width           =   795
  225.       End
  226.       Begin VB.Label Label19 
  227.          AutoSize        =   -1  'True
  228.          Caption         =   "Fade Level:"
  229.          Height          =   195
  230.          Left            =   465
  231.          TabIndex        =   64
  232.          Top             =   1740
  233.          Width           =   840
  234.       End
  235.       Begin VB.Label Label18 
  236.          AutoSize        =   -1  'True
  237.          Caption         =   "Attack Time:"
  238.          Height          =   195
  239.          Left            =   405
  240.          TabIndex        =   63
  241.          Top             =   1170
  242.          Width           =   900
  243.       End
  244.       Begin VB.Label Label17 
  245.          AutoSize        =   -1  'True
  246.          Caption         =   "Attack Level:"
  247.          Height          =   195
  248.          Left            =   360
  249.          TabIndex        =   62
  250.          Top             =   600
  251.          Width           =   945
  252.       End
  253.    End
  254.    Begin VB.Frame frameTypeContainer 
  255.       Caption         =   "Type-Specific Parameters"
  256.       Height          =   3495
  257.       Left            =   3720
  258.       TabIndex        =   12
  259.       Top             =   240
  260.       Width           =   5415
  261.       Begin VB.Frame frameCondition 
  262.          Caption         =   "Conditional Force"
  263.          Height          =   3015
  264.          Left            =   120
  265.          TabIndex        =   37
  266.          Top             =   240
  267.          Visible         =   0   'False
  268.          Width           =   5175
  269.          Begin VB.OptionButton optConditionAxis 
  270.             Caption         =   "Y Axis"
  271.             Height          =   255
  272.             Index           =   1
  273.             Left            =   2280
  274.             TabIndex        =   80
  275.             Top             =   2700
  276.             Width           =   735
  277.          End
  278.          Begin VB.OptionButton optConditionAxis 
  279.             Caption         =   "X Axis"
  280.             Height          =   255
  281.             Index           =   0
  282.             Left            =   2280
  283.             TabIndex        =   79
  284.             Top             =   2440
  285.             Value           =   -1  'True
  286.             Width           =   735
  287.          End
  288.          Begin MSComctlLib.Slider sldCondition 
  289.             Height          =   255
  290.             Index           =   0
  291.             Left            =   240
  292.             TabIndex        =   38
  293.             Top             =   600
  294.             Width           =   2055
  295.             _ExtentX        =   3625
  296.             _ExtentY        =   450
  297.             _Version        =   393216
  298.             LargeChange     =   100
  299.             SmallChange     =   10
  300.             Max             =   10000
  301.             TickFrequency   =   1000
  302.          End
  303.          Begin MSComctlLib.Slider sldCondition 
  304.             Height          =   255
  305.             Index           =   1
  306.             Left            =   240
  307.             TabIndex        =   39
  308.             Top             =   1320
  309.             Width           =   2055
  310.             _ExtentX        =   3625
  311.             _ExtentY        =   450
  312.             _Version        =   393216
  313.             LargeChange     =   100
  314.             SmallChange     =   10
  315.             Min             =   -10000
  316.             Max             =   10000
  317.             TickFrequency   =   1000
  318.          End
  319.          Begin MSComctlLib.Slider sldCondition 
  320.             Height          =   255
  321.             Index           =   2
  322.             Left            =   240
  323.             TabIndex        =   40
  324.             Top             =   2160
  325.             Width           =   2055
  326.             _ExtentX        =   3625
  327.             _ExtentY        =   450
  328.             _Version        =   393216
  329.             LargeChange     =   100
  330.             SmallChange     =   10
  331.             Max             =   10000
  332.             SelStart        =   10000
  333.             TickFrequency   =   1000
  334.             Value           =   10000
  335.          End
  336.          Begin MSComctlLib.Slider sldCondition 
  337.             Height          =   255
  338.             Index           =   3
  339.             Left            =   2880
  340.             TabIndex        =   41
  341.             Top             =   600
  342.             Width           =   2055
  343.             _ExtentX        =   3625
  344.             _ExtentY        =   450
  345.             _Version        =   393216
  346.             LargeChange     =   100
  347.             SmallChange     =   10
  348.             Min             =   -10000
  349.             Max             =   10000
  350.             TickFrequency   =   1000
  351.          End
  352.          Begin MSComctlLib.Slider sldCondition 
  353.             Height          =   255
  354.             Index           =   4
  355.             Left            =   2880
  356.             TabIndex        =   42
  357.             Top             =   1320
  358.             Width           =   2055
  359.             _ExtentX        =   3625
  360.             _ExtentY        =   450
  361.             _Version        =   393216
  362.             LargeChange     =   100
  363.             SmallChange     =   10
  364.             Min             =   -10000
  365.             Max             =   10000
  366.             TickFrequency   =   1000
  367.          End
  368.          Begin MSComctlLib.Slider sldCondition 
  369.             Height          =   255
  370.             Index           =   5
  371.             Left            =   2880
  372.             TabIndex        =   43
  373.             Top             =   2160
  374.             Width           =   2055
  375.             _ExtentX        =   3625
  376.             _ExtentY        =   450
  377.             _Version        =   393216
  378.             LargeChange     =   100
  379.             SmallChange     =   10
  380.             Max             =   10000
  381.             SelStart        =   10000
  382.             TickFrequency   =   1000
  383.             Value           =   10000
  384.          End
  385.          Begin VB.Label Label11 
  386.             AutoSize        =   -1  'True
  387.             Caption         =   "Dead band:"
  388.             Height          =   195
  389.             Left            =   240
  390.             TabIndex        =   55
  391.             Top             =   360
  392.             Width           =   840
  393.          End
  394.          Begin VB.Label Label12 
  395.             AutoSize        =   -1  'True
  396.             Caption         =   "Negative Coefficient:"
  397.             Height          =   195
  398.             Left            =   240
  399.             TabIndex        =   54
  400.             Top             =   1080
  401.             Width           =   1455
  402.          End
  403.          Begin VB.Label Label13 
  404.             AutoSize        =   -1  'True
  405.             Caption         =   "Negative Saturation:"
  406.             Height          =   195
  407.             Left            =   240
  408.             TabIndex        =   53
  409.             Top             =   1920
  410.             Width           =   1455
  411.          End
  412.          Begin VB.Label Label14 
  413.             AutoSize        =   -1  'True
  414.             Caption         =   "Offset:"
  415.             Height          =   195
  416.             Left            =   3120
  417.             TabIndex        =   52
  418.             Top             =   360
  419.             Width           =   465
  420.          End
  421.          Begin VB.Label Label15 
  422.             AutoSize        =   -1  'True
  423.             Caption         =   "Positive Coefficient:"
  424.             Height          =   195
  425.             Left            =   3000
  426.             TabIndex        =   51
  427.             Top             =   1080
  428.             Width           =   1365
  429.          End
  430.          Begin VB.Label Label16 
  431.             AutoSize        =   -1  'True
  432.             Caption         =   "Positive Saturation:"
  433.             Height          =   195
  434.             Left            =   3000
  435.             TabIndex        =   50
  436.             Top             =   1920
  437.             Width           =   1365
  438.          End
  439.          Begin VB.Label lblCondition 
  440.             AutoSize        =   -1  'True
  441.             Caption         =   "0"
  442.             Height          =   195
  443.             Index           =   0
  444.             Left            =   1200
  445.             TabIndex        =   49
  446.             Top             =   360
  447.             Width           =   90
  448.          End
  449.          Begin VB.Label lblCondition 
  450.             AutoSize        =   -1  'True
  451.             Caption         =   "0"
  452.             Height          =   195
  453.             Index           =   1
  454.             Left            =   1800
  455.             TabIndex        =   48
  456.             Top             =   1080
  457.             Width           =   90
  458.          End
  459.          Begin VB.Label lblCondition 
  460.             AutoSize        =   -1  'True
  461.             Caption         =   "10000"
  462.             Height          =   195
  463.             Index           =   2
  464.             Left            =   1800
  465.             TabIndex        =   47
  466.             Top             =   1920
  467.             Width           =   450
  468.          End
  469.          Begin VB.Label lblCondition 
  470.             AutoSize        =   -1  'True
  471.             Caption         =   "0"
  472.             Height          =   195
  473.             Index           =   3
  474.             Left            =   3600
  475.             TabIndex        =   46
  476.             Top             =   360
  477.             Width           =   90
  478.          End
  479.          Begin VB.Label lblCondition 
  480.             AutoSize        =   -1  'True
  481.             Caption         =   "0"
  482.             Height          =   195
  483.             Index           =   4
  484.             Left            =   4440
  485.             TabIndex        =   45
  486.             Top             =   1080
  487.             Width           =   90
  488.          End
  489.          Begin VB.Label lblCondition 
  490.             AutoSize        =   -1  'True
  491.             Caption         =   "10000"
  492.             Height          =   195
  493.             Index           =   5
  494.             Left            =   4410
  495.             TabIndex        =   44
  496.             Top             =   1920
  497.             Width           =   450
  498.          End
  499.       End
  500.       Begin VB.Frame framePeriodic 
  501.          Caption         =   "Periodic Force"
  502.          Height          =   3015
  503.          Left            =   120
  504.          TabIndex        =   24
  505.          Top             =   240
  506.          Visible         =   0   'False
  507.          Width           =   5175
  508.          Begin MSComctlLib.Slider sldPeriodic 
  509.             Height          =   255
  510.             Index           =   0
  511.             Left            =   600
  512.             TabIndex        =   25
  513.             Top             =   480
  514.             Width           =   4095
  515.             _ExtentX        =   7223
  516.             _ExtentY        =   450
  517.             _Version        =   393216
  518.             LargeChange     =   100
  519.             SmallChange     =   10
  520.             Max             =   10000
  521.             TickFrequency   =   1000
  522.          End
  523.          Begin MSComctlLib.Slider sldPeriodic 
  524.             Height          =   255
  525.             Index           =   1
  526.             Left            =   600
  527.             TabIndex        =   26
  528.             Top             =   1080
  529.             Width           =   4095
  530.             _ExtentX        =   7223
  531.             _ExtentY        =   450
  532.             _Version        =   393216
  533.             LargeChange     =   1000
  534.             SmallChange     =   100
  535.             Min             =   -10000
  536.             Max             =   10000
  537.             TickFrequency   =   1000
  538.          End
  539.          Begin MSComctlLib.Slider sldPeriodic 
  540.             Height          =   255
  541.             Index           =   2
  542.             Left            =   600
  543.             TabIndex        =   27
  544.             Top             =   1800
  545.             Width           =   4095
  546.             _ExtentX        =   7223
  547.             _ExtentY        =   450
  548.             _Version        =   393216
  549.             LargeChange     =   1000
  550.             SmallChange     =   100
  551.             Max             =   35999
  552.             TickFrequency   =   1000
  553.          End
  554.          Begin MSComctlLib.Slider sldPeriodic 
  555.             Height          =   255
  556.             Index           =   3
  557.             Left            =   600
  558.             TabIndex        =   28
  559.             Top             =   2520
  560.             Width           =   4095
  561.             _ExtentX        =   7223
  562.             _ExtentY        =   450
  563.             _Version        =   393216
  564.             LargeChange     =   1000
  565.             SmallChange     =   100
  566.             Max             =   500000
  567.             TickFrequency   =   10000
  568.          End
  569.          Begin VB.Label lblPeriodic 
  570.             AutoSize        =   -1  'True
  571.             Caption         =   "0"
  572.             Height          =   195
  573.             Index           =   3
  574.             Left            =   2400
  575.             TabIndex        =   36
  576.             Top             =   2280
  577.             Width           =   90
  578.          End
  579.          Begin VB.Label Label10 
  580.             AutoSize        =   -1  'True
  581.             Caption         =   "Period:"
  582.             Height          =   195
  583.             Left            =   1800
  584.             TabIndex        =   35
  585.             Top             =   2280
  586.             Width           =   495
  587.          End
  588.          Begin VB.Label lblPeriodic 
  589.             AutoSize        =   -1  'True
  590.             Caption         =   "0"
  591.             Height          =   195
  592.             Index           =   2
  593.             Left            =   2400
  594.             TabIndex        =   34
  595.             Top             =   1560
  596.             Width           =   90
  597.          End
  598.          Begin VB.Label Label9 
  599.             AutoSize        =   -1  'True
  600.             Caption         =   "Phase:"
  601.             Height          =   195
  602.             Left            =   1800
  603.             TabIndex        =   33
  604.             Top             =   1560
  605.             Width           =   495
  606.          End
  607.          Begin VB.Label lblPeriodic 
  608.             AutoSize        =   -1  'True
  609.             Caption         =   "0"
  610.             Height          =   195
  611.             Index           =   1
  612.             Left            =   2400
  613.             TabIndex        =   32
  614.             Top             =   840
  615.             Width           =   90
  616.          End
  617.          Begin VB.Label Label8 
  618.             AutoSize        =   -1  'True
  619.             Caption         =   "Offset:"
  620.             Height          =   195
  621.             Left            =   1800
  622.             TabIndex        =   31
  623.             Top             =   840
  624.             Width           =   465
  625.          End
  626.          Begin VB.Label lblPeriodic 
  627.             AutoSize        =   -1  'True
  628.             Caption         =   "0"
  629.             Height          =   195
  630.             Index           =   0
  631.             Left            =   2400
  632.             TabIndex        =   30
  633.             Top             =   240
  634.             Width           =   90
  635.          End
  636.          Begin VB.Label Label7 
  637.             AutoSize        =   -1  'True
  638.             Caption         =   "Magnitude:"
  639.             Height          =   195
  640.             Left            =   1560
  641.             TabIndex        =   29
  642.             Top             =   240
  643.             Width           =   795
  644.          End
  645.       End
  646.       Begin VB.Frame frameRampForce 
  647.          Caption         =   "Ramp Force"
  648.          Height          =   3015
  649.          Left            =   120
  650.          TabIndex        =   17
  651.          Top             =   240
  652.          Width           =   5175
  653.          Begin MSComctlLib.Slider sldRampRange 
  654.             Height          =   495
  655.             Index           =   0
  656.             Left            =   480
  657.             TabIndex        =   18
  658.             Top             =   840
  659.             Width           =   4215
  660.             _ExtentX        =   7435
  661.             _ExtentY        =   873
  662.             _Version        =   393216
  663.             LargeChange     =   1000
  664.             SmallChange     =   100
  665.             Min             =   -10000
  666.             Max             =   10000
  667.             TickFrequency   =   1000
  668.          End
  669.          Begin MSComctlLib.Slider sldRampRange 
  670.             Height          =   495
  671.             Index           =   1
  672.             Left            =   480
  673.             TabIndex        =   19
  674.             Top             =   1920
  675.             Width           =   4215
  676.             _ExtentX        =   7435
  677.             _ExtentY        =   873
  678.             _Version        =   393216
  679.             LargeChange     =   1000
  680.             SmallChange     =   100
  681.             Min             =   -10000
  682.             Max             =   10000
  683.             TickFrequency   =   1000
  684.          End
  685.          Begin VB.Label lblRange 
  686.             AutoSize        =   -1  'True
  687.             Caption         =   "0"
  688.             Height          =   195
  689.             Index           =   1
  690.             Left            =   2400
  691.             TabIndex        =   23
  692.             Top             =   1680
  693.             Width           =   90
  694.          End
  695.          Begin VB.Label Label2 
  696.             AutoSize        =   -1  'True
  697.             Caption         =   "Range End:"
  698.             Height          =   195
  699.             Left            =   1440
  700.             TabIndex        =   22
  701.             Top             =   1680
  702.             Width           =   855
  703.          End
  704.          Begin VB.Label lblRange 
  705.             AutoSize        =   -1  'True
  706.             Caption         =   "0"
  707.             Height          =   195
  708.             Index           =   0
  709.             Left            =   2400
  710.             TabIndex        =   21
  711.             Top             =   600
  712.             Width           =   90
  713.          End
  714.          Begin VB.Label Label1 
  715.             AutoSize        =   -1  'True
  716.             Caption         =   "Range Start:"
  717.             Height          =   195
  718.             Left            =   1440
  719.             TabIndex        =   20
  720.             Top             =   600
  721.             Width           =   900
  722.          End
  723.       End
  724.       Begin VB.Frame frameConstantForce 
  725.          Caption         =   "Constant Force"
  726.          Height          =   3015
  727.          Left            =   120
  728.          TabIndex        =   13
  729.          Top             =   240
  730.          Visible         =   0   'False
  731.          Width           =   5175
  732.          Begin MSComctlLib.Slider sldConstantForce 
  733.             Height          =   495
  734.             Left            =   840
  735.             TabIndex        =   14
  736.             Top             =   1320
  737.             Width           =   3615
  738.             _ExtentX        =   6376
  739.             _ExtentY        =   873
  740.             _Version        =   393216
  741.             LargeChange     =   100
  742.             SmallChange     =   10
  743.             Max             =   10000
  744.             SelStart        =   10000
  745.             TickFrequency   =   1000
  746.             Value           =   10000
  747.          End
  748.          Begin VB.Label lblConstantForce 
  749.             AutoSize        =   -1  'True
  750.             Caption         =   "10000"
  751.             Height          =   195
  752.             Left            =   3360
  753.             TabIndex        =   16
  754.             Top             =   1080
  755.             Width           =   450
  756.          End
  757.          Begin VB.Label Label5 
  758.             AutoSize        =   -1  'True
  759.             Caption         =   "Constant Force Magnitude:"
  760.             Height          =   195
  761.             Left            =   1320
  762.             TabIndex        =   15
  763.             Top             =   1080
  764.             Width           =   1920
  765.          End
  766.       End
  767.    End
  768.    Begin VB.Frame frmGeneral 
  769.       Caption         =   "General Parameters"
  770.       Height          =   2895
  771.       Left            =   120
  772.       TabIndex        =   1
  773.       Top             =   3960
  774.       Width           =   3375
  775.       Begin MSComctlLib.Slider sldDuration 
  776.          Height          =   495
  777.          Left            =   240
  778.          TabIndex        =   2
  779.          Top             =   600
  780.          Width           =   2775
  781.          _ExtentX        =   4895
  782.          _ExtentY        =   873
  783.          _Version        =   393216
  784.          LargeChange     =   100
  785.          SmallChange     =   10
  786.          Min             =   1
  787.          Max             =   50001
  788.          SelStart        =   50001
  789.          TickFrequency   =   5000
  790.          Value           =   50001
  791.       End
  792.       Begin MSComctlLib.Slider sldGain 
  793.          Height          =   495
  794.          Left            =   240
  795.          TabIndex        =   5
  796.          Top             =   1320
  797.          Width           =   2775
  798.          _ExtentX        =   4895
  799.          _ExtentY        =   873
  800.          _Version        =   393216
  801.          LargeChange     =   100
  802.          SmallChange     =   10
  803.          Max             =   10000
  804.          SelStart        =   10000
  805.          TickFrequency   =   1000
  806.          Value           =   10000
  807.       End
  808.       Begin MSComctlLib.Slider sldSamplePeriod 
  809.          Height          =   495
  810.          Left            =   240
  811.          TabIndex        =   9
  812.          Top             =   2160
  813.          Width           =   2775
  814.          _ExtentX        =   4895
  815.          _ExtentY        =   873
  816.          _Version        =   393216
  817.          LargeChange     =   1000
  818.          SmallChange     =   100
  819.          Max             =   100000
  820.          TickFrequency   =   10000
  821.       End
  822.       Begin VB.Label lblSamplePeriod 
  823.          AutoSize        =   -1  'True
  824.          Caption         =   "Default"
  825.          Height          =   195
  826.          Left            =   1320
  827.          TabIndex        =   11
  828.          Top             =   1920
  829.          Width           =   510
  830.       End
  831.       Begin VB.Label Label6 
  832.          AutoSize        =   -1  'True
  833.          Caption         =   "Sample rate:"
  834.          Height          =   195
  835.          Left            =   360
  836.          TabIndex        =   10
  837.          Top             =   1920
  838.          Width           =   885
  839.       End
  840.       Begin VB.Label lblGain 
  841.          AutoSize        =   -1  'True
  842.          Caption         =   "10000"
  843.          Height          =   195
  844.          Left            =   1200
  845.          TabIndex        =   7
  846.          Top             =   1080
  847.          Width           =   450
  848.       End
  849.       Begin VB.Label Label4 
  850.          AutoSize        =   -1  'True
  851.          Caption         =   "Effect gain:"
  852.          Height          =   195
  853.          Left            =   360
  854.          TabIndex        =   6
  855.          Top             =   1080
  856.          Width           =   810
  857.       End
  858.       Begin VB.Label lblDuration 
  859.          AutoSize        =   -1  'True
  860.          Caption         =   "Infinite"
  861.          Height          =   195
  862.          Left            =   1560
  863.          TabIndex        =   4
  864.          Top             =   360
  865.          Width           =   465
  866.       End
  867.       Begin VB.Label Label3 
  868.          AutoSize        =   -1  'True
  869.          Caption         =   "Effect Duration:"
  870.          Height          =   195
  871.          Left            =   360
  872.          TabIndex        =   3
  873.          Top             =   360
  874.          Width           =   1110
  875.       End
  876.    End
  877.    Begin VB.ListBox lstEffects 
  878.       Height          =   3375
  879.       Left            =   120
  880.       TabIndex        =   0
  881.       Top             =   360
  882.       Width           =   3375
  883.    End
  884.    Begin VB.Label lblAvailable 
  885.       AutoSize        =   -1  'True
  886.       Caption         =   "Available effects:"
  887.       Height          =   195
  888.       Left            =   120
  889.       TabIndex        =   8
  890.       Top             =   120
  891.       Width           =   1215
  892.    End
  893. Attribute VB_Name = "frmForceFeedback"
  894. Attribute VB_GlobalNameSpace = False
  895. Attribute VB_Creatable = False
  896. Attribute VB_PredeclaredId = True
  897. Attribute VB_Exposed = False
  898. '''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
  899. '  Copyright (C) 1999-2001 Microsoft Corporation.  All Rights Reserved.
  900. '  File:       ForceFeedback.frm
  901. '  Content:    Demonstrates the use of force feedback using
  902. '              stock dinput effects
  903. '''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
  904. Option Explicit
  905. Dim dx As New DirectX8                                  'DirectX 8 object
  906. Dim di As DirectInput8                                  'DirectInput object
  907. Dim diJoystick As DirectInputDevice8                    'DirectInput device object
  908. Dim enumDevice As DirectInputEnumDevices8               'DirectInput enumeration for devices object
  909. Dim diEnumObjects As DirectInputEnumDeviceObjects       'DirectInput enumeration for objects on a device object
  910. Dim diDevObjInstance As DirectInputDeviceObjectInstance 'DirectInput object on a device object
  911. Dim diEffEnum As DirectInputEnumEffects                 'DirectInput enumeration for force feedback effects object
  912. Dim diFFEffect() As DirectInputEffect                   'Force feedback effects object
  913. Dim diEffectType As Long                                'Will be used to store the type of effect an effect object is
  914. Dim diFFStaticParams As Long                            'Will be used to store the static parameters of an effect object
  915. Dim EffectParams() As Long                              'Used to store the type of effect it is
  916. Dim Caps As DIDEVCAPS                                   'Will be used to store the capabilities of the diJoystick
  917. Dim lngLastEffectIndex As Long                          'Will be used to store the last effect
  918. Dim bInit As Boolean
  919. Private Function CreateFFEffect(Index As Integer) As DIEFFECT
  920.     'This sub creates a generic effect DIEFFECT structure to be used in creating the effect
  921.     With CreateFFEffect
  922.         .lDuration = &HFFFFFFFF                         'Infinite duration
  923.         .lGain = 10000                                  'Full gain
  924.         .lSamplePeriod = 1000                           'Default sample period
  925.         .lTriggerButton = DIEB_NOTRIGGER                'Do Not require a trigger for the effects
  926.         .lTriggerRepeatInterval = -1                    'Turn off trigger repeat interval
  927.                 
  928.         .constantForce.lMagnitude = 10000               'Make the magnitude of a constant force effect at full
  929.         .rampForce.lRangeStart = 0                      'Make the magnitude at the start of a ramp force 0
  930.         .rampForce.lRangeEnd = 0                        'Make the magnitude at the end of a ramp force 0
  931.         .conditionFlags = DICONDITION_USE_BOTH_AXES     'Use both axis when using a conditional force
  932.         With .conditionX                                'For the X axis
  933.             .lDeadBand = 0                              'Make an effect with no deadband
  934.             .lNegativeSaturation = 10000                'Turn the negative saturation all the way up
  935.             .lOffset = 0                                'Zero the offset
  936.             .lPositiveSaturation = 10000                'Turn the positive saturation all the way up
  937.         End With
  938.         With .conditionY                                'For the Y axis
  939.             .lDeadBand = 0                              'Make an effect with no deadband
  940.             .lNegativeSaturation = 10000                'Turn the negative saturation all the way up
  941.             .lOffset = 0                                'Zero the offset
  942.             .lPositiveSaturation = 10000                'Turn the positive saturation all the way up
  943.         End With
  944.         With .periodicForce                             'For a periodic force
  945.             .lMagnitude = 10000                         'Turn the magnitude of the force all the way up
  946.             .lOffset = 0                                'Zero the offset
  947.             .lPeriod = 0                                'Set the length of a cycle to 0. This tells the driver to use the default.
  948.             .lPhase = 0                                 'Zero the starting phase. Phase is something that has very
  949.                                                         'limited support, so changing this parameter will almost always
  950.                                                         'fail. Be prepared to catch the error this will return.
  951.         End With
  952.     End With
  953. End Function
  954. Private Sub chkEnvelope_Click()
  955.     Call ChangeParameter("envelope")                    'Call the sub to change the parameters for the envelope of the effect.
  956.             
  957. End Sub
  958. Private Sub Form_Activate()
  959.     Dim i As Long                                       'Count variable
  960.     Dim j As Integer                                    'Count variable
  961.     Dim prop As DIPROPLONG                              'Device property structure
  962.     Dim diedo As DirectInputEnumDeviceObjects           'Holds the collection of individual objects on a device
  963.     Dim didoi As DirectInputDeviceObjectInstance        'Holds the instance of an object on a device
  964.     Dim lFFAxisCount As Long                            'Holds the number of axis that support FF
  965.     Set di = dx.DirectInputCreate                       'Create the direct input device
  966.     Set enumDevice = di.GetDIDevices(DI8DEVCLASS_GAMECTRL, DIEDFL_ATTACHEDONLY Or DIEDFL_FORCEFEEDBACK)
  967.                                                         'Enumerate all joysticks that are attached to the system
  968.     For i = 1 To enumDevice.GetCount
  969.         
  970.         Set diJoystick = di.CreateDevice(enumDevice.GetItem(i).GetGuidInstance)
  971.         diJoystick.GetCapabilities Caps                 'Get the capabilites of the device
  972.         Set diedo = diJoystick.GetDeviceObjectsEnum(DIDFT_AXIS) ' Get info about all the axis on the device
  973.         
  974.         'This loops through to make sure that there
  975.         'are at least two axis that support FF
  976.         For j = 1 To diedo.GetCount
  977.             Set didoi = diedo.GetItem(j)
  978.             If (didoi.GetFlags And DIDOI_FFACTUATOR) Then
  979.                 lFFAxisCount = lFFAxisCount + 1
  980.             End If
  981.         Next
  982.         
  983.         If lFFAxisCount > 1 Then
  984.         
  985.             diJoystick.SetCommonDataFormat DIFORMAT_JOYSTICK    'Set the format of the device to that of a joystick
  986.             diJoystick.SetCooperativeLevel Me.hWnd, DISCL_BACKGROUND Or DISCL_EXCLUSIVE
  987.                                                                 'Set the cooperative level of the device as an exclusive
  988.                                                                 'background device, and attach it to the form's hwnd
  989.             prop.lData = 0
  990.             prop.lHow = DIPH_DEVICE
  991.             prop.lObj = 0
  992.             Call diJoystick.SetProperty("DIPROP_AUTOCENTER", prop)  'Turn off autocenter
  993.             
  994.             diJoystick.Acquire                          'Make sure to aquire the device
  995.             Set diEffEnum = diJoystick.GetEffectsEnum(DIEFT_ALL)
  996.                                                         'Enumerate all the available effects
  997.             For j = 1 To diEffEnum.GetCount             'Loop through all the effects
  998.                 diEffectType = diEffEnum.GetType(j) And &HFF
  999.                                                         'Filter out the major type of effect it is
  1000.                 diFFStaticParams = diEffEnum.GetStaticParams(j)
  1001.                                                         'Get the static parameters of this effect
  1002.                 If (diEffectType = DIEFT_HARDWARE) And _
  1003.                 (diFFStaticParams And DIEP_TYPESPECIFICPARAMS) <> 0 Then
  1004.                                                         'If this is a hardware effect that has type-specific parameters,
  1005.                     GoTo Ignore                         'ignore it and skip to the next effect
  1006.                 ElseIf diEffectType = DIEFT_CUSTOMFORCE Then
  1007.                                                         'If this effect is a custom effect,
  1008.                     GoTo Ignore                         'ignore it and skip to the next effect
  1009.                 End If
  1010.                 lstEffects.AddItem diEffEnum.GetName(j)
  1011.                                                         'Add this effect to the listbox, displaying the name of the
  1012.                                                         'effect
  1013.                 ReDim Preserve EffectParams(lstEffects.ListCount - 1)
  1014.                                                         'Redimension the array that stores the type of effect this
  1015.                                                         'effect is
  1016.                 EffectParams(lstEffects.ListCount - 1) = diEffectType
  1017.                                                         'store the type of effect in the EffectParams array
  1018.                 ReDim Preserve diFFEffect(lstEffects.ListCount - 1)
  1019.                                                         'Redimension the effect object array
  1020.                 
  1021.                 On Local Error GoTo ErrorHandler        'Catch any errors when creating the effect object
  1022.                 Set diFFEffect(UBound(diFFEffect)) = diJoystick.CreateEffect(diEffEnum.GetEffectGuid(j), _
  1023.                 CreateFFEffect(j))                      'Create the effect, using the return value from the
  1024.                                                         'CreateFFEffect function, which returns a generic effect
  1025.                                                         'structure
  1026.                 diFFEffect(UBound(diFFEffect)).Unload   'Since creating an effect automtically downloads it, unload
  1027.                                                         'it so we don't run out of room on the device.
  1028. Ignore:
  1029.             Next
  1030.             Exit For                                    'Keep the first FF joystick found
  1031.         Else
  1032.             Set diJoystick = Nothing                    'Destroy this device and try again if there are more devices
  1033.         End If
  1034.     Next
  1035.     If diJoystick Is Nothing Then                       'If no FF joystick is found attached to the system
  1036.         MsgBox "No force feedback joystick attached, app will exit"    'Display this message
  1037.         Unload Me                                       'Unload the form
  1038.         End                                             'End the program
  1039.     End If
  1040.     If diFFEffect(0) Is Nothing Then                    'If this device has no downloadable effects, end the app
  1041.         MsgBox "This device does not contain any downloadable effects, app will exit"
  1042.         Unload Me                                       'Unload the form
  1043.         End                                             'End the program
  1044.     End If
  1045.     lngLastEffectIndex = UBound(diFFEffect)             'Store the ubound of the effect array as the last effect accessed
  1046.     bInit = True
  1047.     lstEffects.ListIndex = 0                            'make the first index of the listbox selected
  1048.             
  1049.     Exit Sub                                            'Exit the sub
  1050. ErrorHandler:                                           'Handle any errors that occur when trying to create an effect object
  1051.     If Err.Number = 5 Then                              'If this is an effect that isn't able to be loaded
  1052.         If lstEffects.ListCount > 0 Then
  1053.             lstEffects.RemoveItem lstEffects.ListCount - 1          'Remove the item from the list
  1054.             If (lstEffects.ListCount > 0) Then
  1055.                 ReDim Preserve diFFEffect(lstEffects.ListCount - 1)     'Redimension the array since this effect will not be included
  1056.                 ReDim Preserve EffectParams(lstEffects.ListCount - 1)   'Redimension the effect params array as well
  1057.             Else
  1058.                 Erase diFFEffect
  1059.                 Erase EffectParams
  1060.             End If
  1061.         End If
  1062.         Err.Clear
  1063.         GoTo Ignore                                     'Skip this effect
  1064.         
  1065.     ElseIf Err.Number = DIERR_NOTEXCLUSIVEACQUIRED Then 'If the program loses exclusive use of the joystick,
  1066.         diJoystick.Unacquire                            'Unacquire the joystick
  1067.         diJoystick.SetCooperativeLevel Me.hWnd, DISCL_BACKGROUND Or DISCL_EXCLUSIVE
  1068.                                                         'Set the cooperative level again
  1069.         diJoystick.Acquire                              'Acquire the joystick again
  1070.         Resume                                          'Resume execution on that line again, since the program
  1071.                                                         'now has control of the joystick
  1072.     End If
  1073. End Sub
  1074. Private Sub lstEffects_Click()
  1075.     If bInit = False Then Exit Sub
  1076.     'This sub unloads the last effect, downloads the new one, stores the index in the last effect variable, and
  1077.     'calls the sub to update all the frames and controls on the form
  1078.     Dim EffectInfo As DIEFFECT                          'Dim a DIEFFECT structure
  1079.     On Local Error GoTo ErrorHandler                    'Catch any errors while unloading/downloading effects
  1080.     diFFEffect(lngLastEffectIndex).Unload               'Unload the last effect
  1081.     diFFEffect(lstEffects.ListIndex).Start 1, 0         'Start the effect playing (this will also download the effect)
  1082.     lngLastEffectIndex = lstEffects.ListIndex           'Store this list index  in the lasteffectindex variable
  1083.     Call UpdateFrames                                   'Call the sub that updates all the frames and the controls
  1084.                                                         'they contain on the form
  1085.     Exit Sub
  1086. ErrorHandler:                                           'Handle any errors
  1087.     If Err.Number = DIERR_NOTEXCLUSIVEACQUIRED Then     'If the program loses exclusive use of the joystick,
  1088.         diJoystick.Unacquire                            'Unacquire the joystick
  1089.         diJoystick.SetCooperativeLevel Me.hWnd, DISCL_BACKGROUND Or DISCL_EXCLUSIVE
  1090.                                                         'Set the cooperative level again
  1091.         diJoystick.Acquire                              'Acquire the joystick again
  1092.         Resume                                          'Resume execution on that line again, since the program
  1093.                                                         'now has control of the joystick
  1094.     End If
  1095. End Sub
  1096. Private Sub ChangeParameter(Param As String)
  1097.     On Local Error GoTo ErrorHandler
  1098.     'This sub changes the specified parameter
  1099.     If lstEffects.ListIndex = -1 Then Exit Sub
  1100.     Dim EffectInfo As DIEFFECT                          'Dim a DIEFFECT structure
  1101.     diFFEffect(lstEffects.ListIndex).GetParameters EffectInfo
  1102.                                                         'Get the parameters of this effect
  1103.     On Local Error GoTo ErrorHandler                    'If there are any errors that occur, trap them
  1104.         
  1105.     Select Case Param                                   'Select the string value passed to the sub
  1106.         Case "duration"                                 'If duration is being changed
  1107.             If sldDuration = 50001 Then                 'If the slider's value is at 50,001
  1108.                 EffectInfo.lDuration = -1               'Then make the effect have an infinite duration
  1109.             Else                                        'Otherwise
  1110.                 EffectInfo.lDuration = sldDuration * 100
  1111.                                                         'Multiply the slider's value by 100 to convert to microseconds
  1112.             End If
  1113.             diFFEffect(lstEffects.ListIndex).Stop
  1114.             diFFEffect(lstEffects.ListIndex).SetParameters EffectInfo, DIEP_DURATION
  1115.                                                         'Set the new parameter, specifiying the duration is what needs
  1116.                                                         'to be changed
  1117.             diFFEffect(lstEffects.ListIndex).Start 1, 0
  1118.         Case "gain"                                     'If gain is the parameter to be changed,
  1119.             EffectInfo.lGain = sldGain                  'Set the effect info element lGain to the value of the gain slider
  1120.             diFFEffect(lstEffects.ListIndex).SetParameters EffectInfo, DIEP_GAIN
  1121.                                                         'Set the new gain
  1122.         Case "samplerate"                               'The sample rate is the parameter to be changed
  1123.             EffectInfo.lSamplePeriod = sldSamplePeriod  'Set the effectinfo lSamplePeriod to the value of the sample period slider
  1124.             diFFEffect(lstEffects.ListIndex).SetParameters EffectInfo, DIEP_SAMPLEPERIOD
  1125.                                                         'Set the parameter
  1126.         Case "constantforcemagnitude"                   'If the constant force magnitude is to be changed
  1127.             EffectInfo.constantForce.lMagnitude = sldConstantForce
  1128.                                                         'Set the constant force element to the value of the constant
  1129.                                                         'force slider
  1130.             diFFEffect(lstEffects.ListIndex).SetParameters EffectInfo, DIEP_TYPESPECIFICPARAMS
  1131.                                                         'Change the parameter
  1132.         Case "rampforce"                                'If ramp force is the parameter to change
  1133.             EffectInfo.rampForce.lRangeStart = sldRampRange(0).Value
  1134.                                                         'Set the start range to the range slider(0) value
  1135.             EffectInfo.rampForce.lRangeEnd = sldRampRange(1).Value
  1136.                                                         'Set the end range to the range slider(1) value
  1137.             diFFEffect(lstEffects.ListIndex).SetParameters EffectInfo, DIEP_TYPESPECIFICPARAMS
  1138.                                                         'Set the parameters
  1139.         Case "periodic"                                 'If a periodic effect parameter needs to be changed
  1140.             With EffectInfo.periodicForce
  1141.                 .lMagnitude = sldPeriodic(0)            'set the magnitude
  1142.                 .lOffset = sldPeriodic(1)               'the offset
  1143.                 .lPhase = sldPeriodic(2)                'the phase (this is almost always going to fail, there aren't
  1144.                                                         'a lot of drivers that will support this)
  1145.                 .lPeriod = sldPeriodic(3)               'the period of the effect
  1146.             End With
  1147.             diFFEffect(lstEffects.ListIndex).SetParameters EffectInfo, DIEP_TYPESPECIFICPARAMS
  1148.                                                         'set the parameters
  1149.         Case "condition"                                'If it is a conditional effect parameter
  1150.             If optConditionAxis(0) Then                 'If the X axis is selected
  1151.                 With EffectInfo.conditionX              'Update the X axis condition information
  1152.                     .lDeadBand = sldCondition(0)        'set the deadband
  1153.                     .lNegativeCoefficient = sldCondition(1)
  1154.                                                         'set the negative coefficient
  1155.                     .lNegativeSaturation = sldCondition(2)
  1156.                                                         'set the negative saturation
  1157.                     .lOffset = sldCondition(3)          'set the offset
  1158.                     .lPositiveCoefficient = sldCondition(4)
  1159.                                                         'set the positive coefficient
  1160.                     .lPositiveSaturation = sldCondition(5)
  1161.                                                         'set the positive saturation
  1162.                 End With
  1163.             Else                                        'Otherwise, the Y axis is being set
  1164.                 With EffectInfo.conditionY
  1165.                     .lDeadBand = sldCondition(0)        'set the deadband
  1166.                     .lNegativeCoefficient = sldCondition(1)
  1167.                                                         'set the negative coefficient
  1168.                     .lNegativeSaturation = sldCondition(2)
  1169.                                                         'set the negative saturation
  1170.                     .lOffset = sldCondition(3)          'set the offset
  1171.                     .lPositiveCoefficient = sldCondition(4)
  1172.                                                         'set the positive coefficient
  1173.                     .lPositiveSaturation = sldCondition(5)
  1174.                                                         'set the positive saturation
  1175.                 End With
  1176.             End If
  1177.             diFFEffect(lstEffects.ListIndex).SetParameters EffectInfo, DIEP_TYPESPECIFICPARAMS
  1178.                                                         'set the parameters
  1179.         Case "envelope"                                 'the envelope needs to be changed
  1180.             If chkEnvelope.Value = 1 Then               'if the envelope checkbox is checked
  1181.                 With EffectInfo
  1182.                     .bUseEnvelope = True                'let DirectInput know this effect has an envelope
  1183.                     With .envelope
  1184.                         .lAttackLevel = sldEnvelope(0)  'set the attack level
  1185.                         .lAttackTime = sldEnvelope(1)   'set the attack time
  1186.                         .lFadeLevel = sldEnvelope(2)    'set the fade level
  1187.                         .lFadeTime = sldEnvelope(3)     'set the fade time
  1188.                     End With
  1189.                 End With
  1190.                 diFFEffect(lstEffects.ListIndex).SetParameters EffectInfo, DIEP_ENVELOPE
  1191.                                                         'Set the new parameters
  1192.             Else
  1193.                 EffectInfo.bUseEnvelope = False         'Otherwise, let DirectInput know that this effect doesn't use an envelope
  1194.                 diFFEffect(lstEffects.ListIndex).SetParameters EffectInfo, DIEP_ENVELOPE
  1195.                                                         'Set the parameters to reflect this change
  1196.             End If
  1197.         Case "direction"                                'Direction is the parameter that needs to be changed
  1198.             With EffectInfo
  1199.                 If optDirection(0) Then                 'If the north button is selected
  1200.                     .x = 0                              'set the effect's direction to come from the north
  1201.                 ElseIf optDirection(1) Then             'If the north-east button is selected
  1202.                     .x = 4500                           'set the effect's direction to come from the north-east
  1203.                 ElseIf optDirection(2) Then             'if the east button is selected
  1204.                     .x = 9000                           'set the effect's direction to come from the east
  1205.                 ElseIf optDirection(3) Then             'if the south-east button is selected
  1206.                     .x = 13500                          'set the effect's direction to come from the south east
  1207.                 ElseIf optDirection(4) Then             'if the south button is selected
  1208.                     .x = 18000                          'set the effect's direction to come from the south
  1209.                 ElseIf optDirection(5) Then             'if the south-west button is selected
  1210.                     .x = 22500                          'set the effect's direction to come from the south-west
  1211.                 ElseIf optDirection(6) Then             'if the west button is selected
  1212.                     .x = 27000                          'set the effect's direction to come from the west
  1213.                 ElseIf optDirection(7) Then             'if the north-west button is selected
  1214.                     .x = 31500                          'set the effects's direction to come from the north-west
  1215.                 End If
  1216.             End With
  1217.             diFFEffect(lstEffects.ListIndex).SetParameters EffectInfo, DIEP_DIRECTION
  1218.                                                         'set the parameters
  1219.     End Select
  1220.         
  1221.     Exit Sub
  1222. ErrorHandler:                                           'if an error is encountered while setting a parameter
  1223.     If Err.Number = 445 Then                            'If the object doesn't support this action then
  1224.         MsgBox "The parameter cannot be set to this value for this effect type"
  1225.                                                         'display this message
  1226.     ElseIf Err.Number = DIERR_NOTEXCLUSIVEACQUIRED Then 'If the program loses exclusive use of the joystick,
  1227.         diJoystick.Unacquire                            'Unacquire the joystick
  1228.         diJoystick.SetCooperativeLevel Me.hWnd, DISCL_BACKGROUND Or DISCL_EXCLUSIVE
  1229.                                                         'Set the cooperative level again
  1230.         diJoystick.Acquire                              'Acquire the joystick again
  1231.         Resume                                          'Resume execution on that line again, since the program
  1232.                                                         'now has control of the joystick
  1233.     End If
  1234. End Sub
  1235. Private Sub UpdateFrames()
  1236.     'This sub updates all the frames and controls the frame contains on the form, with the values in the
  1237.     'currently selected effect
  1238.     Dim EffType As DIEFFECT                             'dim a DIEFFECT structure
  1239.         
  1240.     frameConstantForce.Visible = False                  '
  1241.     frameRampForce.Visible = False                      'Hide all type-specific frames
  1242.     framePeriodic.Visible = False                       '
  1243.     frameCondition.Visible = False                      '
  1244.     diFFEffect(lstEffects.ListIndex).GetParameters EffType
  1245.                                                         'get the parameters of the effect
  1246.     optDirection(EffType.x \ 4500).Value = True         'make sure the correct direction is displayed
  1247.     If EffType.bUseEnvelope = True Then                 'if this effect is using an envelope
  1248.         chkEnvelope.Value = 1                           'make sure the envelope checkbox is checked
  1249.         sldEnvelope(0).Value = EffType.envelope.lAttackLevel
  1250.                                                         'display the attack level
  1251.         sldEnvelope(1).Value = EffType.envelope.lAttackTime
  1252.                                                         'display the attack time
  1253.         sldEnvelope(2).Value = EffType.envelope.lFadeLevel
  1254.                                                         'display the fade level
  1255.         sldEnvelope(3).Value = EffType.envelope.lFadeTime
  1256.                                                         'display the fade time
  1257.     Else                                                'otherwise
  1258.         chkEnvelope.Value = 0                           '
  1259.         sldEnvelope(0).Value = 0                        'Zero everything out
  1260.         sldEnvelope(1).Value = 0                        '
  1261.         sldEnvelope(2).Value = 0                        '
  1262.         sldEnvelope(3).Value = 0                        '
  1263.     End If
  1264.     If EffType.lDuration = -1 Then                      'If the effect duration is infinite
  1265.         sldDuration = 50001                             'make sure the slider reflects this
  1266.     Else                                                'otherwise
  1267.         sldDuration = EffType.lDuration \ 100           'set the slider to the milliseconds
  1268.     End If
  1269.     sldGain = EffType.lGain                             'display the gain
  1270.     sldSamplePeriod = EffType.lSamplePeriod             'display the sample period
  1271.     sldConstantForce = EffType.constantForce.lMagnitude 'display the constant force magnitude
  1272.     sldRampRange(0) = EffType.rampForce.lRangeStart     'display the range start of the ramp force
  1273.     sldRampRange(1) = EffType.rampForce.lRangeEnd       'display the range end of the ramp force
  1274.     sldPeriodic(0) = EffType.periodicForce.lMagnitude   'display the magnitude of the periodic force
  1275.     sldPeriodic(1) = EffType.periodicForce.lOffset      'display the offset of the periodic force
  1276.     sldPeriodic(2) = EffType.periodicForce.lPhase       'display the phase of the periodic force
  1277.     sldPeriodic(3) = EffType.periodicForce.lPeriod      'display the period of the periodic force
  1278.     If optConditionAxis(0) Then                         'if the X axis option button is selected
  1279.         sldCondition(0) = EffType.conditionX.lDeadBand  'display the deadband value
  1280.         sldCondition(1) = EffType.conditionX.lNegativeCoefficient
  1281.                                                         'display the neg. coefficient
  1282.         sldCondition(2) = EffType.conditionX.lNegativeSaturation
  1283.                                                         'display the neg. saturation
  1284.         sldCondition(3) = EffType.conditionX.lOffset    'display the offset
  1285.         sldCondition(4) = EffType.conditionX.lPositiveCoefficient
  1286.                                                         'display the pos. coefficient
  1287.         sldCondition(5) = EffType.conditionX.lPositiveSaturation
  1288.                                                         'display the pos. saturation
  1289.     Else                                                'otherwise, display all the info for the Y axis
  1290.         sldCondition(0) = EffType.conditionY.lDeadBand  'display the deadband value
  1291.         sldCondition(1) = EffType.conditionY.lNegativeCoefficient
  1292.                                                         'display the neg. coefficient
  1293.         sldCondition(2) = EffType.conditionY.lNegativeSaturation
  1294.                                                         'display the neg. saturation
  1295.         sldCondition(3) = EffType.conditionY.lOffset    'display the offset
  1296.         sldCondition(4) = EffType.conditionY.lPositiveCoefficient
  1297.                                                         'display the pos. coefficient
  1298.         sldCondition(5) = EffType.conditionY.lPositiveSaturation
  1299.                                                         'display the pos. saturation
  1300.     End If
  1301.     Select Case EffectParams(lstEffects.ListIndex)
  1302.                                                         'Get the effect type of this effect from the type stored in
  1303.                                                         'the array.
  1304.         Case DIEFT_CONSTANTFORCE                        'If this is a constant force effect
  1305.             frameConstantForce.Visible = True           'display the constant force frame
  1306.         Case DIEFT_RAMPFORCE                            'If this is a ramp force effect
  1307.             frameRampForce.Visible = True               'Show the ramp force frame
  1308.         Case DIEFT_PERIODIC                             'If this is a square force
  1309.             framePeriodic.Visible = True                'show the periodic effect frame
  1310.         Case DIEFT_CONDITION                              'if this is a spring effect
  1311.             frameCondition.Visible = True               'show the condition frame
  1312.         Case Else                                       'this effect is a hardware effect with no type-specific parameters
  1313.     End Select
  1314. End Sub
  1315. Private Sub optConditionAxis_Click(Index As Integer)
  1316.     Call UpdateFrames                                   'Update the frames
  1317. End Sub
  1318. Private Sub optDirection_Click(Index As Integer)
  1319.     Call ChangeParameter("direction")                   'Change the direction parameter
  1320. End Sub
  1321. Private Sub sldCondition_Change(Index As Integer)
  1322.     lblCondition(Index) = sldCondition(Index)           'display the value in the label
  1323.     Call ChangeParameter("condition")                   'change the condition parameter
  1324. End Sub
  1325. Private Sub sldCondition_Scroll(Index As Integer)
  1326.     lblCondition(Index) = sldCondition(Index)           'display the value in the label
  1327.     Call ChangeParameter("condition")                   'change the condition parameter
  1328. End Sub
  1329. Private Sub sldConstantForce_Change()
  1330.     lblConstantForce = sldConstantForce                 'display the value
  1331.     Call ChangeParameter("constantforcemagnitude")      'change the parameter
  1332. End Sub
  1333. Private Sub sldDuration_Change()
  1334.     lblDuration = sldDuration \ 10 & " Milliseconds"    'show the value in milliseconds
  1335.     If sldDuration = 50001 Then lblDuration = "Infinite"
  1336.                                                         'if the value is 50,001 make sure that infinite is displayed
  1337.     Call ChangeParameter("duration")                    'change the duration parameter
  1338. End Sub
  1339. Private Sub sldDuration_Scroll()
  1340.     lblDuration = sldDuration \ 10 & " Milliseconds"    'show the value in milliseconds
  1341.     If sldDuration = 50001 Then lblDuration = "Infinite"
  1342.                                                         'if the value is 50,001 make sure that infinite is displayed
  1343.     Call ChangeParameter("duration")                    'change the duration parameter
  1344. End Sub
  1345. Private Sub sldEnvelope_Change(Index As Integer)
  1346.     lblEnvelope(Index) = sldEnvelope(Index) \ 1000      'show the value in milliseconds
  1347.     If chkEnvelope.Value = 1 Then                       'if the envelope check box is checked
  1348.         Call ChangeParameter("envelope")                'change the envelope parameter
  1349.     End If
  1350. End Sub
  1351. Private Sub sldEnvelope_Scroll(Index As Integer)
  1352.     lblEnvelope(Index) = sldEnvelope(Index) \ 1000      'show the value in milliseconds
  1353.     If chkEnvelope.Value = 1 Then                       'if the envelope check box is checked
  1354.         Call ChangeParameter("envelope")                'change the envelope parameter
  1355.     End If
  1356. End Sub
  1357. Private Sub sldGain_Change()
  1358.     lblGain = sldGain                                   'show the value
  1359.     Call ChangeParameter("gain")                        'change the parameter
  1360. End Sub
  1361. Private Sub sldGain_Scroll()
  1362.     lblGain = sldGain                                   'show the value
  1363.     Call ChangeParameter("gain")                        'change the parameter
  1364. End Sub
  1365. Private Sub sldPeriodic_Change(Index As Integer)
  1366.     lblPeriodic(Index) = sldPeriodic(Index)             'show the value
  1367.     Call ChangeParameter("periodic")                    'change the parameter
  1368.                 
  1369. End Sub
  1370. Private Sub sldrampRange_Change(Index As Integer)
  1371.     lblRange(Index) = sldRampRange(Index).Value         'show the value
  1372.     Call ChangeParameter("rampforce")                   'change the parameter
  1373. End Sub
  1374. Private Sub sldSamplePeriod_Change()
  1375.     If sldSamplePeriod = 0 Then                         'if the sample period is 0,
  1376.         lblSamplePeriod = "Default"                     'display that it is the default
  1377.     Else                                                'otherwise
  1378.         lblSamplePeriod = sldSamplePeriod               'display the sample period
  1379.     End If
  1380.     Call ChangeParameter("samplerate")                  'change the parameter
  1381. End Sub
  1382. Private Sub sldSamplePeriod_Scroll()
  1383.     If sldSamplePeriod = 0 Then                         'if the sample period is 0,
  1384.         lblSamplePeriod = "Default"                     'display that it is the default
  1385.     Else                                                'otherwise
  1386.         lblSamplePeriod = sldSamplePeriod               'display the sample period
  1387.     End If
  1388.     Call ChangeParameter("samplerate")                  'change the parameter
  1389. End Sub
  1390.